{% extends "base_generic.html" %}
{% block script %}
<script type="text/javascript">
function generateUrl(name) {
  var sanitizedName = string_to_slug(name);
  $("#url").val(sanitizedName);
}
</script>
{% endblock %}

{% block content %}
    <form name="edit-admin" id="edit-admin" method="post" action="{{path}}">
    <div id="primaryContentContainer">
      <div id="primaryContent">
      {% if error %}
      <div class="error">{{errormessage}}</div>
      {% endif %}
        <div>
          <h2>Name:</h2>
          <p><input type="text" name="name" id="name" value="{{tag.name}}" onblur="generateUrl($('#name').val())" /></p>
        </div>
        <div>
          <h2>Language:</h2>
          <p>{% for alanguage in languages %}
{% if forloop.first %}
<select name="language" id="language">
{% endif %}
<option value="{{alanguage.url}}" {% ifequal alanguage.url language %}selected="selected"{% endifequal %}>{{alanguage.name}}</option>
{% if forloop.last %}
</select>
{% endif %}
{% endfor %}</p>
        </div>

<div>
<input type="submit" name="save" class="mainbutton" id="publish" value="Save" /><input type="hidden" name="url" id="url" value="{{tag.url}}" />
</div>
      </div>
    </div>
</form>
{% endblock %}
